/** - - - 获取文件或目录的状态 - - - */ 

// 导入fs模块
const fs = require('fs');
// 导入path模块
const path = require( 'path' );

// 以当前文件所在目录为处理目标
let pathname = __dirname ;

let callback = (error,stats) => {
    if( error ) {
        console.log( error.name , error.message );
        return ;
    }
    console.log( '- - - - - 状态信息 - - - - -' );
    console.log( stats );
    console.log( 'is directory:' , stats.isDirectory() );
}

// 异步获取文件或目录的状态
// https://nodejs.org/dist/latest-v16.x/docs/api/fs.html#fsstatpath-options-callback
// fs.stat( pathname [, options] , callback )
fs.stat( pathname , callback );
console.log( 'hello' );

// 以当前文件为处理目标
pathname = __filename;

// 同步获取文件或目录的状态
// https://nodejs.org/dist/latest-v16.x/docs/api/fs.html#fsstatsyncpath-options
// let stats = fs.statSync( pathname [, options] )
let stats = fs.statSync( pathname );
console.log( '= = = = = 状态信息 = = = = =' );
console.log( stats );
console.log( 'is file: ' , stats.isFile() );